<template>
  <div>
    <city-header></city-header>
    <city-search :citys="citys"></city-search>
    <city-list :hotCitys="hotCitys" :citys="citys" :letter="letter"></city-list>
    <abc-array :citys="citys" @change="handleLetterChange"></abc-array>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from '@/pages/city/components/CityHeader'
import CitySearch from '@/pages/city/components/CitySearch'
import CityList from '@/pages/city/components/CityList'
import AbcArray from '@/pages/city/components/AbcArray'
export default {
  name: 'City',
  data () {
    return {
      citys: {},
      hotCitys: [],
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    AbcArray
  },
  methods: {
    getCityData () {
      axios.get('/static/api/city.json')
        .then(this.getCityDataSucc)
    },
    getCityDataSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        this.citys = res.data.cities
        this.hotCitys = res.data.hotCities
      }
    },
    handleLetterChange (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getCityData()
  }
}
</script>

<style lang="stylus" scoped>

</style>
